import {request} from "./request";

export function getUser(id) {
  return request({
    method: "get",
    url: `router.php?s=user/${id}/`
  })
}

export function collectAns(id, answer_id) {
  return request({
    method: "post",
    url: `router.php?t=user/collectAnswer/${id}/${answer_id}/`
  })
}

export function disCollectAns(id, answer_id) {
  return request({
    method: "delete",
    url: `router.php?t=user/disCollectAnswer/${id}/${answer_id}/`
  })
}

export function thumbUpAns(id, answer_id) {
  return request({
    method: "post",
    url: `router.php?t=user/thumbUpAnswer/${id}/${answer_id}/`
  })
}

export function unThumbUpAns(id, answer_id) {
  return request({
    method: "delete",
    url: `router.php?t=user/unThumbUpAnswer/${id}/${answer_id}/`
  })
}

export function followUser(id, target_id) {
  return request({
    method: "post",
    url: `router.php?t=user/followUser/${id}/${target_id}/`
  })
}

export function unFollowUser(id, target_id) {
  return request({
    method: "post",
    url: `router.php?t=user/unFollowUser/${id}/${target_id}/`
  })
}

export function checkIsFollowed(id, target_id) {
  return request({
    method: "get",
    url: `router.php?t=user/checkIsFollowed/${id}/${target_id}/`
  })
}

export function getUserCollect(id) {
  return request({
    method: "get",
    url: `router.php?t=user/getCollects/${id}/`
  })
}

export function getUserAns(id) {
  return request({
    method: "get",
    url: `router.php?t=user/getAnswer/${id}/`
  })
}

export function getFollowInfo(id) {
  return request({
    method: "get",
    url: `router.php?t=user/getFollowInfo/${id}/`
  })
}

export function updateUserInfo(id, obj) {
  return request({
    method: "put",
    url: `router.php?s=user/${id}/`,
    data: JSON.stringify(obj)
  })
}

export function uploadPhoto(id, formData) {
  return request({
    method: "post",
    url: `router.php?t=user/uploadPhoto/${id}/`,
    data: formData
  })
}


